-- @owner: cr13
-- @date: 2023-05-17
-- @testpoint: opengauss关键字allocate(非保留)，作为触发器名，合理报错

--step1:创建源表 expect:成功
drop table if exists t_keywords_allocate_0030;
create table t_keywords_allocate_0030(id1 INT, id2 INT, id3 INT);

--step2:创建触发器函数 expect:成功
create or replace function tri_insert_func() returns trigger as  $$  
declare
begin 
    insert into test_trigger_des_tbl VALUES(NEW.id1, NEW.id2, NEW.id3);
    return new;
end
$$ language plpgsql;
/

--step3:创建INSERT触发器不带引号 expect:创建成功
drop trigger if exists allocate on t_keywords_allocate_0030;
create trigger allocate before insert on t_keywords_allocate_0030 for each row execute procedure tri_insert_func();
/

--step4:创建INSERT触发器带双引号 expect:创建成功
drop trigger if exists "allocate" on t_keywords_allocate_0030;
create trigger "allocate" before insert on t_keywords_allocate_0030 for each row execute procedure tri_insert_func();
/

--step5:创建INSERT触发器带单引号 expect:合理报错
drop trigger if exists 'allocate' on t_keywords_allocate_0030;
create trigger 'allocate' before insert on t_keywords_allocate_0030 for each row execute procedure tri_insert_func();
/

--step6:创建INSERT触发器带反单引号 expect:合理报错
drop trigger if exists `admin` on t_keywords_allocate_0030;
create trigger `admin` before insert on t_keywords_allocate_0030 for each row execute procedure tri_insert_func();
/

--step7:清理环境 expect:成功
drop trigger if exists allocate on t_keywords_allocate_0030;
drop function tri_insert_func;
drop table if exists t_keywords_allocate_0030;